<?php 	
	header('Access-Control-Allow-Origin: *');
	header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
	header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE');
	include('connect.php');

	$name = $_POST['name'];
	$permssion = $_POST['permission'];
	$pwd = md5($_POST['pwd']);

	$loginkey = md5(mt_rand().'!@#$'.'linyu');

	$rows = [];

	$sql = 'insert into admin values (null,"'.$name.'","'.$pwd.'","1000","'.$loginkey.'","'.$permssion.'")';

	$result = $db->query($sql);

	if($result){
		$rows['code'] = '20000';
		$rows['msg'] = '添加账号成功';
	}else{
		$rows['code'] = '20001';
		$rows['msg'] = '添加账号失败';
	}
	echo json_encode($rows);